package org.jivesoftware.smack.util;

import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;

public class ObservableReader extends Reader
{
  List listeners;
  Reader wrappedReader = null;

  public ObservableReader(Reader paramReader)
  {
    this.listeners = new ArrayList();
    this.wrappedReader = paramReader;
  }

  public void addReaderListener(ReaderListener paramReaderListener)
  {
    if (paramReaderListener == null)
      return;
    synchronized (this.listeners)
    {
      if (!(this.listeners.contains(paramReaderListener)))
        this.listeners.add(paramReaderListener);
    }
  }

  public void close()
    throws IOException
  {
    this.wrappedReader.close();
  }

  public void mark(int paramInt)
    throws IOException
  {
    this.wrappedReader.mark(paramInt);
  }

  public boolean markSupported()
  {
    return this.wrappedReader.markSupported();
  }

  public int read()
    throws IOException
  {
    return this.wrappedReader.read();
  }

  public int read(char[] paramArrayOfChar)
    throws IOException
  {
    return this.wrappedReader.read(paramArrayOfChar);
  }

  // ERROR //
  public int read(char[] paramArrayOfChar, int paramInt1, int paramInt2)
    throws IOException
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 15	org/jivesoftware/smack/util/ObservableReader:wrappedReader	Ljava/io/Reader;
    //   4: aload_1
    //   5: iload_2
    //   6: iload_3
    //   7: invokevirtual 54	java/io/Reader:read	([CII)I
    //   10: istore 4
    //   12: iload 4
    //   14: ifle +70 -> 84
    //   17: new 56	java/lang/String
    //   20: dup
    //   21: aload_1
    //   22: iload_2
    //   23: iload 4
    //   25: invokespecial 59	java/lang/String:<init>	([CII)V
    //   28: astore 5
    //   30: aconst_null
    //   31: checkcast 61	[Lorg/jivesoftware/smack/util/ReaderListener;
    //   34: pop
    //   35: aload_0
    //   36: getfield 20	org/jivesoftware/smack/util/ObservableReader:listeners	Ljava/util/List;
    //   39: astore 7
    //   41: aload 7
    //   43: monitorenter
    //   44: aload_0
    //   45: getfield 20	org/jivesoftware/smack/util/ObservableReader:listeners	Ljava/util/List;
    //   48: invokeinterface 64 1 0
    //   53: anewarray 66	org/jivesoftware/smack/util/ReaderListener
    //   56: astore 9
    //   58: aload_0
    //   59: getfield 20	org/jivesoftware/smack/util/ObservableReader:listeners	Ljava/util/List;
    //   62: aload 9
    //   64: invokeinterface 70 2 0
    //   69: pop
    //   70: aload 7
    //   72: monitorexit
    //   73: iconst_0
    //   74: istore 11
    //   76: iload 11
    //   78: aload 9
    //   80: arraylength
    //   81: if_icmplt +14 -> 95
    //   84: iload 4
    //   86: ireturn
    //   87: astore 8
    //   89: aload 7
    //   91: monitorexit
    //   92: aload 8
    //   94: athrow
    //   95: aload 9
    //   97: iload 11
    //   99: aaload
    //   100: aload 5
    //   102: invokeinterface 73 2 0
    //   107: iinc 11 1
    //   110: goto -34 -> 76
    //
    // Exception table:
    //   from	to	target	type
    //   44	73	87	finally
    //   89	92	87	finally
  }

  public boolean ready()
    throws IOException
  {
    return this.wrappedReader.ready();
  }

  public void removeReaderListener(ReaderListener paramReaderListener)
  {
    synchronized (this.listeners)
    {
      this.listeners.remove(paramReaderListener);
      return;
    }
  }

  public void reset()
    throws IOException
  {
    this.wrappedReader.reset();
  }

  public long skip(long paramLong)
    throws IOException
  {
    return this.wrappedReader.skip(paramLong);
  }
}